import { Service } from 'egg';
export default class User extends Service {

    public async login(data) {
        console.log(data)
        if (data.username == 'admin' && data.password == '123456') {
            return {
                status: 200,
                message: '请求成功',
                data: {
                    token: 'admin-token'
                }
            }
        } else if (data.username == 'edit' && data.password == '123456') {
            return {
                status: 200,
                message: '请求成功',
                data: {
                    token: 'edit-token'
                }
            }
        } else {
            return {
                status: 403,
                message: '您的密码或账号错误'
            }
        }
    }

    public async userinfo(query) {
        console.log(query)
        if (query.token == 'admin-token') {
            return {
                status: 200,
                data: {
                    'id': '4291d7da9005377ec9aec4a71ea837f',
                    'name': '尊敬的VUE交流组成员',
                    'username': 'admin',
                    'password': '',
                    'avatar': '/avatar2.jpg',
                    'status': 1,
                    'telephone': '',
                    'lastLoginIp': '27.154.74.117',
                    'lastLoginTime': 1534837621348,
                    'creatorId': 'admin',
                    'createTime': 1497160610259,
                    'merchantCode': 'TLif2btpzg079h15bk',
                    'deleted': 0,
                    'role': ['admin']
                }
            }
        } else {
            return {
                status: 200,
                data: {
                    username: 'edit',
                    email: 'xxx@qq.com'
                }
            }
        }
    }
}
